import { createStore } from 'vuex'
import app from './modules/app'
import user from './modules/user'
import asset from './modules/asset'
import finance from './modules/finance'
import material from './modules/material'
import todo from './modules/todo'
import mobile from './modules/mobile'
import message from './modules/message'
import search from './modules/search'
import createPersistedState from 'vuex-persistedstate'

// 创建状态存储
export default createStore({
  state: {
    user: {
      name: '张医生',
      position: '主治医师',
      department: '神经外科',
      avatar: 'https://randomuser.me/api/portraits/men/85.jpg'
    },
    stats: {
      todo: 12,
      assets: 5,
      requests: 3
    },
    notifications: [
      {
        id: 1,
        content: '您有 3 个待办事项需要处理，1 个报销申请待审批'
      }
    ]
  },
  getters: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    app,    // 应用全局状态
    user,   // 用户信息状态
    asset,  // 资产模块状态
    finance, // 财务模块状态
    material, // 物资模块状态
    todo,    // 待办事项状态
    mobile,   // 新版移动端状态
    message,
    search
  },
  plugins: [
    createPersistedState({
      key: 'hplus-mobile',
      paths: ['message.unreadCount', 'search.history']
    })
  ]
}) 